package cn.ctodb.mall.goods.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

import cn.ctodb.mall.goods.domain.enumeration.IsCheck;

/**
 * A GoodsType.
 */
@Entity
@Table(name = "goods_type")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "goodstype")
public class GoodsType implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(name = "cat_name")
    private String catName;

    @Enumerated(EnumType.STRING)
    @Column(name = "enabled")
    private IsCheck enabled;

    @Column(name = "attr_group")
    private String attrGroup;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCatName() {
        return catName;
    }

    public GoodsType catName(String catName) {
        this.catName = catName;
        return this;
    }

    public void setCatName(String catName) {
        this.catName = catName;
    }

    public IsCheck getEnabled() {
        return enabled;
    }

    public GoodsType enabled(IsCheck enabled) {
        this.enabled = enabled;
        return this;
    }

    public void setEnabled(IsCheck enabled) {
        this.enabled = enabled;
    }

    public String getAttrGroup() {
        return attrGroup;
    }

    public GoodsType attrGroup(String attrGroup) {
        this.attrGroup = attrGroup;
        return this;
    }

    public void setAttrGroup(String attrGroup) {
        this.attrGroup = attrGroup;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GoodsType goodsType = (GoodsType) o;
        if (goodsType.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, goodsType.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "GoodsType{" +
            "id=" + id +
            ", catName='" + catName + "'" +
            ", enabled='" + enabled + "'" +
            ", attrGroup='" + attrGroup + "'" +
            '}';
    }
}
